package com.ffyc.cemp.web.controller;

import com.ffyc.cemp.common.dto.HttpResult;
import com.ffyc.cemp.domain.entity.Schedule;
import com.ffyc.cemp.domain.vo.ScheduleVo;
import com.ffyc.cemp.services.service.IScheduleService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;
import java.util.Map;

@Api(tags = "排片api接口")
@RestController
@RequestMapping("/api/schedule")
public class ScheduleController {

    @Autowired
    private IScheduleService iss;

    @PostMapping("/addSchedule")
    public HttpResult addSchedule(@RequestBody Schedule schedule) {
        iss.addSchedule(schedule);
        return HttpResult.success("添加排片成功");
    }


    @ApiOperation(value = "findSchedules", notes = "查询所有的任务")
    @GetMapping("/findSchedules")
    public HttpResult<Map<String, List<ScheduleVo>>> findSchedules() {
        return HttpResult.success(iss.findAllSchedule());
    }

    @ApiOperation(value = "findScheduleByMovie", notes = "查询自定电影的放映计划")
    @GetMapping("/findScheduleByMovie")
    public  HttpResult<List<ScheduleVo>> findScheduleByMovie(int movieId){
        return HttpResult.success(iss.findScheduleByMovieId(movieId));
    }
}
